﻿<UserControl x:Class="Gao.Poker.App.UserControls.CompetitionSetting"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Domain="clr-namespace:Gao.Poker.Domain;assembly=Domain" mc:Ignorable="d" >
    <Grid Margin="0">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*"/>
            <ColumnDefinition Width="8*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="40.73"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="50"/>
        </Grid.RowDefinitions>
        <Border BorderBrush="White" BorderThickness="0,1" Margin="0,1,0,0" Grid.ColumnSpan="3">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#A1C7CFDA" Offset="0.991"/>
                    <GradientStop Color="#B5F1F1F1"/>
                    <GradientStop Color="#FFD2D2D2" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
        </Border>
        <StackPanel Margin="0" Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="2">
            <Button Content="新增" Name="btnNew" HorizontalAlignment="Left" Style="{DynamicResource MyButton}" Width="101" Height="25" />
            <Border BorderBrush="#CCFFFFFF" BorderThickness="1,0,0,0" HorizontalAlignment="Left"  Width="2.5" Background="#FFB6B6B6"/>
            <Button Content="报名" Name="btnApply" HorizontalAlignment="Left" Style="{DynamicResource MyButton}" Width="101" Height="25" />
            <Border BorderBrush="#CCFFFFFF" BorderThickness="1,0,0,0" HorizontalAlignment="Left"  Width="2.5" Background="#FFB6B6B6"/>
            <Button Content="买入" Name="btnBuy" HorizontalAlignment="Left" Style="{DynamicResource MyButton}" Width="101" Height="25" />
            <Border BorderBrush="#CCFFFFFF" BorderThickness="1,0,0,0" HorizontalAlignment="Left"  Width="2.5" Background="#FFB6B6B6"/>
        </StackPanel>

        <DockPanel Margin="0" Grid.Column="0" Grid.Row="1">
            <ListView Name="listView" Margin="0,0,0,0" DockPanel.Dock="Top" ItemsSource="{Binding Path=Competitions}" 
                      SelectedItem="{Binding Path=Competition,Mode=TwoWay}" Padding="0"
              VirtualizingStackPanel.VirtualizationMode="Recycling">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="*" />
                            </Grid.ColumnDefinitions>
                            <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Margin="0">
                                <TextBlock FontWeight="Bold"
                                        Text="{Binding Path=Name}" />
                                <TextBlock Text="{Binding Path=Date, StringFormat='yyyy-MM-dd'}"
                                        TextTrimming="CharacterEllipsis" />
                            </StackPanel>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </DockPanel>
        <ScrollViewer Margin="5" Grid.Column="1" Grid.Row="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="600"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="120"/>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="*"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>

                <TextBlock Text="比赛名称：" Margin="1" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center" HorizontalAlignment="Right"/>
                <TextBox Text="{Binding Path=Competition.Name,Mode=TwoWay}" Margin="1" Grid.Column="1" VerticalContentAlignment="Center" Grid.Row="0"/>

                <TextBlock Text="比赛时间："  Margin="1" VerticalAlignment="Center" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right"/>
                <DatePicker Text="{Binding Path=Competition.Date, Mode=TwoWay}" Margin="1" VerticalContentAlignment="Center"  Grid.Column="1" Grid.Row="1"/>

                <TextBlock Text="选择桌号：" Grid.Column="0" Grid.Row="2" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="1" />
                <ListView Grid.Column="1" Grid.Row="2"  Margin="0,0,0,0" Padding="0" ItemsSource="{Binding Tableses}"
                         SelectionMode="Multiple" VirtualizingStackPanel.VirtualizationMode="Recycling">
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Grid Margin="2">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <StackPanel Grid.Column="0" Grid.ColumnSpan="2" Margin="0">
                                    <TextBlock FontWeight="Bold"
                                        Text="{Binding Path=Number}" />
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                </ListView>

                <TextBlock Text="当前总码数：" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="1" Grid.Column="0" Grid.Row="3"/>
                <TextBox Text="{Binding Path=Competition.TotalBet, Mode=TwoWay}" Margin="1" VerticalContentAlignment="Center"  Grid.Column="1" Grid.Row="3"/>

                <TextBlock Text="买入人数：" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="1" Grid.Column="0" Grid.Row="4"/>
                <TextBox Text="{Binding Path=Competition.BuyNumber, Mode=TwoWay}"  Margin="1" VerticalContentAlignment="Center"  Grid.Column="1" Grid.Row="4"/>

                <TextBlock Text="重新买入人数：" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="1" Grid.Column="0" Grid.Row="5"/>
                <TextBox Text="{Binding Path=Competition.ReBuyNumber, Mode=TwoWay}" Margin="1" VerticalContentAlignment="Center"  Grid.Column="1" Grid.Row="5"/>

                <TextBlock Text="单注金额：" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="1" Grid.Column="0" Grid.Row="6"/>
                <TextBox Text="{Binding Path=Competition.SingleAmount, Mode=TwoWay}" Margin="1" VerticalContentAlignment="Center"  Grid.Column="1" Grid.Row="6"/>

                <TextBlock Text="保底奖金：" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="1" Grid.Column="0" Grid.Row="7"/>
                <TextBox Text="{Binding Path=Competition.DownsideBonus, Mode=TwoWay}" Margin="1" VerticalContentAlignment="Center"  Grid.Column="1" Grid.Row="7"/>

                <TextBlock Text="比赛级别：" HorizontalAlignment="Right" Margin="1" Grid.Column="0" Grid.Row="8"/>
                <DataGrid Margin="1" Height="200" VerticalAlignment="Top" Grid.Column="1"  Grid.Row="8" RowHeight="30" AutoGenerateColumns="False"
                      SelectionMode="Single"  CanUserAddRows="True" CellStyle="{StaticResource Body_Content_DataGrid_Centering}"
                      AlternatingRowBackground="Gainsboro"  AlternationCount="2" 
                      ItemsSource="{Binding Path=Competition.CompetitionLevels, Mode=TwoWay}" FontSize="16">
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="级别" Width="Auto" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=Level, Mode=TwoWay}"/>
                        <DataGridTextColumn Header="比赛时间" Width="80" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=CompetitionTime, Mode=TwoWay}"/>
                        <DataGridTextColumn Header="盲注" Width="120" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=Blind, Mode=TwoWay}"/>
                        <DataGridTextColumn Header="前置休息时间" Width="*" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=AfterRestTime, Mode=TwoWay}"/>
                        <DataGridTextColumn Header="附加前注" Width="*" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=AppendGamble, Mode=TwoWay}"/>
                    </DataGrid.Columns>
                </DataGrid>

                <TextBlock Text="报名人员：" HorizontalAlignment="Right" Margin="1" Grid.Column="0" Grid.Row="9"/>
                <DataGrid Margin="1,1,1.2,1" VerticalAlignment="Top" RowHeight="30" AutoGenerateColumns="False" Grid.Column="1"  Grid.Row="9"
                    SelectionMode="Single"  CanUserAddRows="True" CellStyle="{StaticResource Body_Content_DataGrid_Centering}"
                    AlternatingRowBackground="Gainsboro" ItemsSource="{Binding Members}"  AlternationCount="2" IsReadOnly="True"
                    FontSize="16" Height="297" Name="dgMembers" >
                    <DataGrid.Columns>
                        <DataGridTextColumn Header="ID" Width="40" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=ID}"/>
                        <DataGridTextColumn Header="卡号" Width="120" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=CardNo}"/>
                        <DataGridTextColumn Header="姓名" Width="80" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=Name}"/>
                        <DataGridTextColumn Header="手机号" Width="100" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=Telephone}"/>
                        <DataGridTextColumn Header="积分" Width="*" HeaderStyle="{StaticResource CenterAlignmentColumnHeaderStyle}" Binding="{Binding Path=Points}"/>
                    </DataGrid.Columns>
                </DataGrid>
            </Grid>
        </ScrollViewer>
        <StackPanel Orientation="Horizontal" Grid.ColumnSpan="2"  Grid.Row="3" Margin="5" VerticalAlignment="Center" HorizontalAlignment="Center">
            <Button Padding="5" Style="{DynamicResource Orrange}" Width="60" FontSize="16" Height="35" Name="btnLogin" 
                    Command="{Binding SaveCommand}" CommandParameter="{Binding Competition}">保存</Button>
        </StackPanel>
    </Grid>
</UserControl>
